import { Dialog } from 'vant';
export default {
  data() {
    return {
      //余额
      member_credit2: 0.0,
      //余额字样
      balanceLang: this.fun.getBalanceLang(),
      income_name_text: "",
      show: false,
      dataInfo: {
        balance_button: [],
        balance_log: []
      }, //保存信息
      name: false,
      Navlis: 'day',
      nameOther: [],
      point_statistics:''
    };
  },
  methods: {
    ecological() {
      $http
        .get(
          "plugin.ecological-point.frontend.controllers.page.index",
          { slot_type: this.Navlis },
          "加载中..."
        )
        .then(
          (response) => {
            this.show = true;
            if (response.result == 1) {
              let info_basic = JSON.parse(localStorage.getItem("yz_basic_info"));
              this.balanceLang = info_basic.ecological_point?info_basic.ecological_point:'生态积分';
              this.fun.setWXTitle(this.balanceLang);
              this.dataInfo = response.data;
              this.point_statistics = response.data.point_statistics
            } else {
              this.$dialog.alert({ message: response.msg });
            }
          },
          function (response) {
            this.$dialog.alert({ message: response.msg });

          }
        );
    },
    getBalance() {
      var that = this;
      $http
        .get(
          "finance.balance.index",
          {},
          "加载中..."
        )
        .then(
          (response) => {
            this.show = true;
            if (response.result == 1) {
              this.dataInfo = response.data;
              console.log(this.dataInfo.other, this.dataInfo.balance_button)
            } else {
              that.$dialog.alert({ message: response.msg });
            }
          },
          function (response) {
            that.$dialog.alert({ message: response.msg });

          }
        );
    },
    //转化爱心值
    transformingLoveV() {
      this.$router.push(this.fun.getUrl("transformLoveV"));
    },
    // 猫崽积分功能跳转
    transformingTo(key) {
      this.$router.push(this.fun.getUrl("ecologicalPointAward",{status:key}))
    },
    tourlEclogicalPoint(key,json = {}){
      this.$router.push(this.fun.getUrl(key,json));
    },
    tourl(key, json = {}) {
      if (key == 'Balance_recharge') {
        if (JSON.parse(window.localStorage.getItem("globalParameter")).ios_virtual_pay == "1" && this.fun.isIphone()) {
          this.$dialog.alert({
            message: "十分抱歉，由于相关规定，你暂时无法在这里充值！"
          });
          return false;
        }
        return this.$router.push(this.fun.getUrl('balance_recharge'));
      }
      this.$router.push(this.fun.getUrl(key, json));
    },
    tapNav(key) {
      this.Navlis = key;
      this.ecological()
    },
  },
  activated() {
    if (this.$route.params.name && this.$route.params.name == 'cat') {
      // 如果是猫崽积分
      this.name = this.$route.params.name;
      this.nameOther = [
        {
          img: 'https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2FecologicalPoint%2Frangli%402x.png',
          title: '让利奖励',
          id:1
        },
        {
          img: 'https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2FecologicalPoint%2Fjingxiaoshang%402x.png',
          title: '经销商奖励',
          id:2
        },
        {
          img: 'https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2FecologicalPoint%2Fquyu%402x.png',
          title: '区域奖励',
          id:3
        }
      ]
      this.ecological();
      return
    }
    this.getBalance();
    this.fun.setWXTitle(this.balanceLang)
  }
};